﻿using System.ComponentModel;
using System.Diagnostics.Eventing.Reader;
using VSTalk.Engine.Core.EntitySession;
using VSTalk.Model;
using VSTalk.Tools;

namespace VSTalk.Engine.ViewModel.ContactList.ClientResources
{
    public class InterlocutorResourceItemViewModel : INotifyPropertyChanged
    {
        public IInterlocutorResource ResourceItem { get; set; }

        public string ResourceShow
        {
            get
            {
                if (ResourceItem.Show == ShowType.NONE)
                {
                    return "available";
                }
                return ResourceItem.Show.ToString("G");
            }
        }

        public string ResourceName
        {
            get { return ResourceItem.Jid.Resource; }
        }

        public InterlocutorResourceItemViewModel(IInterlocutorResource resource)
        {
            ResourceItem = resource;
            resource.SubscribeToChange(() => resource.Show, sender => PropertyChanged.Notify(() => ResourceShow));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
